#include <stdio.h>

int ans[13];

int main (){
	int kill,k,n,p;
	long m;
	
	for (k=1;k<=13;k++)
	{
	for (m=k+1;;m++){
		kill=1;p=0;
		for (n=0;n<=(k-1);n++){
			kill=(kill-1+m)%(2*k-n);
			if (kill==0) kill=2*k-n;
			else if (kill<=k) {p=1;break;}
		}
		if (p!=1) break;
	}
		ans[k]=m;
	}
	while(	scanf("%ld", &k),k ) 
	{
		printf ("%ld\n",ans[k]);
	}
}    

